/*
 * @Descripttion: 
 * @version: 0.0.0.1
 * @Author: chenyf15482
 * @Date: 2023-01-29 09:33:08
 * @LastEditors: chenyf15482
 * @LastEditTime: 2023-01-31 16:30:35
 */
import type { ExtractPropTypes } from 'vue'
import { _vueTypeProp } from '@/utils';

export interface TableLeftBtns {
  key: string,
  title?: string,
  size?: string,
  disabled?: string,
  icon?: string,
}

export interface TableRightBtns {
  refresh?: boolean,
}

export interface TableColumns {
  key: string | number,
  type?: string,
  title?: string,
  render?: yAnyFunc<yAny>,
}

// 运行时声明
export const tableProps = {
  tableHeight: _vueTypeProp<number>(Number, undefined),
  leftBtns: _vueTypeProp<TableLeftBtns[]>(Array, () => []),
  rightBtns: _vueTypeProp<TableRightBtns>(Object, () => ({})),
  tableColumns: _vueTypeProp<TableColumns[]>(Array, () => []),
  tableData: _vueTypeProp<yAny[]>(Array, () => []),
  link: _vueTypeProp<yApilink>(Object, () => ({ type: 'mid', url: ''}))
}
export type TableProps = ExtractPropTypes<typeof tableProps>

// 类型声明  因vue文件单独编译  暂不支持类型从外部文件中导入
// export interface tableEmits {
//   (e: 'btnClick', action: string): void
// }
export const tableEmits = {
  btnClick: (action: string) => action
}
export type TableEmits = typeof tableEmits